package com.linxz.ui.searchview;
import android.view.View;
import android.view.ViewGroup;
/**
 * @author Linxz
 * 创建日期：2020年02月21日 23:14
 * version：v4.5.4
 * 描述：
 */
public class ViewMarginWrapper {
    private View view;

    public ViewMarginWrapper(View view){
        this.view=view;
    }

    public void setLeftMargin(int margin) {
        ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        lp.leftMargin = margin;
        view.setLayoutParams(lp);
    }

    public int getLeftMargin(){
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        return marginLayoutParams.leftMargin;
    }

    public void setRightMargin(int margin){
        ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        lp.rightMargin = margin;
        view.setLayoutParams(lp);
    }

    public int getRightMargin(){
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        return marginLayoutParams.rightMargin;
    }


}
